package com.manong.util;

import lombok.Getter;

import java.util.List;

@Getter
public class PageResult<T> {
    private int currentPage;
    private int pageSize;
    private int totalCount;
    private List<T> data;

    private int totalPages;
    private int perPage;
    private int nextPage;

    public PageResult(int currentPage, int pageSize, int totalCount, List<T> data) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.data = data;

        this.totalPages = this.totalCount % this.pageSize == 0 ? this.totalCount / this.pageSize : this.totalCount / this.pageSize + 1;
        this.perPage = this.currentPage - 1 >= 1 ? this.currentPage - 1 : 1;
        this.nextPage = this.currentPage + 1 <= this.totalPages ? this.currentPage + 1 : this.totalPages;
    }
}
